package ch03.test.factory;

import ch03.test.dao.CountDao;
import ch03.test.dao.impl.AdditionCountDaoImpl;
import ch03.test.dao.impl.DivisionCountDaoImpl;
import ch03.test.dao.impl.MultiplicationCountDaoImpl;
import ch03.test.dao.impl.SubtractionCountDaoImpl;

public class CountDaoFactory {
    public static CountDao getInstance(String operator){
        switch (operator){
            case "+":
                return new AdditionCountDaoImpl();
            case "-":
                return new SubtractionCountDaoImpl();
            case "*":
                return new MultiplicationCountDaoImpl();
            case "/":
                return new DivisionCountDaoImpl();
            default:
                throw new RuntimeException("无效的类型:"+operator);
        }
    }
}
